package com.lucker.service.caipiaosimulationplan;



import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lucker.cds.model.CustomCaiPiaoSimulationPlan;
import com.lucker.common.enums.BetPlanDetailStatus;
import com.lucker.common.enums.BetPlanStatus;
import com.lucker.common.enums.GameMode;
import com.lucker.common.enums.VirtualMoneyHistoryType;
import com.lucker.common.enums.VirtualMoneyType;
import com.lucker.common.model.BetAIPlanObj;
import com.lucker.common.model.BetMenuObj;
import com.lucker.common.model.BetObj;
import com.lucker.common.model.BetTargetObj;
import com.lucker.common.model.MyBetListObj;
import com.lucker.common.model.MyBetNumberInfoObj;
import com.lucker.common.model.MyBetPlanDetailObj;
import com.lucker.common.util.CountTotalBonusUtil;
import com.lucker.common.util.DateTimeUtil;
import com.lucker.common.util.StringUtil;
import com.lucker.ds.mapper.BaseCustomMapper;
import com.lucker.ds.model.CaiPiao;
import com.lucker.ds.model.CaiPiaoBetType;
import com.lucker.ds.model.CaiPiaoSimulationCode;
import com.lucker.ds.model.CaiPiaoSimulationDetail;
import com.lucker.ds.model.CaiPiaoSimulationPlan;
import com.lucker.ds.model.EvenyDayOpenTime;
import com.lucker.framework.constant.ResponseBaseModel;
import com.lucker.framework.constant.ResponseResultModel;
import com.lucker.framework.exception.BaseServiceException;
import com.lucker.service.BaseServiceImpl;
import com.lucker.service.caipiao.CaiPiaoService;
import com.lucker.service.caipiaobettype.CaiPiaoBetTypeService;
import com.lucker.service.caipiaosimulationcode.CaiPiaoSimulationCodeService;
import com.lucker.service.caipiaosimulationdetail.CaiPiaoSimulationDetailService;
import com.lucker.service.evenydayopentime.EvenyDayOpenTimeService;
import com.lucker.service.user.UserVirtualMoneyService;

@Service
public class CaiPiaoSimulationPlanServiceImpl extends BaseServiceImpl<CaiPiaoSimulationPlan, CustomCaiPiaoSimulationPlan, Long> 
implements CaiPiaoSimulationPlanService {

	@Autowired
	private CaiPiaoService  caiPiaoService;
	
	@Autowired
	private CaiPiaoSimulationCodeService caiPiaoSimulationCodeService;
	
	@Autowired
	EvenyDayOpenTimeService evenyDayOpenTimeService;
	
	@Autowired
	CaiPiaoSimulationDetailService caiPiaoSimulationDetailService;
	
	@Autowired
	CaiPiaoBetTypeService  caiPiaoBetTypeService;
	
	@Autowired
	UserVirtualMoneyService userVirtualMoneyService;
	
	@Override
	public BaseCustomMapper<CustomCaiPiaoSimulationPlan, Long> getCustomMapper() {
		return null;
	}
	
	@Transactional
	public ResponseEntity<?> bet(Long userId,Long cai_id,BetObj vo) {
		CaiPiaoSimulationPlan _caiPiaoSimulationPlan = packageCaiPiaoSimulationPlan(userId,cai_id,vo);		
        add(_caiPiaoSimulationPlan, false);
		
		/*************************添加投注方案号码*******************************************************/
		
		List<BetTargetObj> _betTargetObjList = vo.getBetTargetObjs();
		for(BetTargetObj obj : _betTargetObjList) {
			CaiPiaoSimulationCode _caiPiaoSimulationCode = new CaiPiaoSimulationCode();
			_caiPiaoSimulationCode.setPlanId(_caiPiaoSimulationPlan.getId());
			_caiPiaoSimulationCode.setGameModeId(Integer.parseInt(obj.getBetMenuObj().getTypeId()));
			_caiPiaoSimulationCode.setGameModeName(obj.getBetMenuObj().getName());
			
			if(CollectionUtils.isNotEmpty(obj.getFirstNumsList())) {
				String _code = StringUtils.join(obj.getFirstNumsList().toArray(), ",");
				_caiPiaoSimulationCode.setBetFristNum(_code);
			}
			
			if(CollectionUtils.isNotEmpty(obj.getSecondNumsList())) {
				String _code = StringUtils.join(obj.getSecondNumsList().toArray(), ",");
				_caiPiaoSimulationCode.setBetSecondNum(_code);
			}
			
			if(CollectionUtils.isNotEmpty(obj.getThirdNumsList())) {
				String _code = StringUtils.join(obj.getThirdNumsList().toArray(), ",");
				_caiPiaoSimulationCode.setBetThirdNum(_code);
			}
			
			caiPiaoSimulationCodeService.add(_caiPiaoSimulationCode, false);
			
		}
		
		
		/*********************************存储方案详情**********************************************/
		
		List<BetAIPlanObj> _betAIPlanObjList = vo.getBetAIPlanObjs();
		int tempIssueNo = 0;
		int count = 1;
		for(BetAIPlanObj p : _betAIPlanObjList) {
			CaiPiaoSimulationDetail _detail = new CaiPiaoSimulationDetail();
			_detail.setPlanId(_caiPiaoSimulationPlan.getId());
			String _issueNo = getLongIssueNo(tempIssueNo,p.getShortIssueno());
			_detail.setFullIssueNo(_issueNo);
			if(count == 1) {
				_detail.setStatus(BetPlanDetailStatus.waitopen.getCode());
			}else {
				_detail.setStatus(BetPlanDetailStatus.waiting.getCode());
			}
			count++;
			_detail.setCurrBetMultiple(p.getMultiple());
			_detail.setInvestment(Long.valueOf(p.getTotalMoney()));
			_detail.setMaxBonus(p.getTotalMoney() + p.getMaxProfit());
			_detail.setMinBonus(p.getTotalMoney() + p.getMinProfit());
			_detail.setCurrentMoney(p.getCurrentMoney());
			
			//取开奖时间
			EvenyDayOpenTime query = new EvenyDayOpenTime();
			query.setCaiId(_caiPiaoSimulationPlan.getCaiId());
			query.setIssueno(_issueNo);
			List<EvenyDayOpenTime> list = evenyDayOpenTimeService.queryAll(query);
			if(CollectionUtils.isEmpty(list)) {
				throw new BaseServiceException("异常  cai_id:" + _caiPiaoSimulationPlan.getCaiId() + " , " + _issueNo + "  这期开奖时间没有维护") ;
			}
			if(list.size() > 1){
				throw new BaseServiceException("异常  cai_id:" + _caiPiaoSimulationPlan.getCaiId() + " , " + _issueNo + "  这期开奖时间维护了多条") ;
			}
			_detail.setOpenTime(list.get(0).getOpenDate());
			
			caiPiaoSimulationDetailService.add(_detail, false);
			tempIssueNo = p.getShortIssueno();
		}
		
		//扣减用户模拟币
		userVirtualMoneyService.addUserVirtualMoney(userId, -(_caiPiaoSimulationPlan.getPlanTotalMoney()), VirtualMoneyType.virtualmoney, VirtualMoneyHistoryType.bet_consume , String.valueOf(_caiPiaoSimulationPlan.getId()));
		
		return new ResponseEntity<>(new ResponseBaseModel(10000,"投注成功！"), HttpStatus.OK);
	}
	
	
	
	@Transactional
	public void	matchOpenCode(Long caiId,int cai_type_id,String issueNo,String openCode) {
		
		//get runing plan by cai_id
		CaiPiaoSimulationPlan queryPlan = new CaiPiaoSimulationPlan();
		queryPlan.setCaiId(caiId);
		queryPlan.setPlanStatus(BetPlanStatus.runing.getCode());
		List<CaiPiaoSimulationPlan> _planList = queryAll(queryPlan);
		
		List<Integer> awardNumbers = StringUtil.stringToListInteger(openCode, ",");
		/****************************/
		//List<BetMenuObj> betMenuListObjs,List<BetTargetObj> betTargetObjs,List<Integer> awardNumbers
		List<BetMenuObj> betMenuListObjs = new ArrayList<BetMenuObj>();
		
		//
		CaiPiaoBetType queryBetType = new CaiPiaoBetType();
		queryBetType.setCaiTypeId(String.valueOf(cai_type_id));
		queryBetType.setGroupId(GameMode.normal.getCode());
		List<CaiPiaoBetType> _gameModeList = caiPiaoBetTypeService.queryAll(queryBetType);
		
		
		for(CaiPiaoBetType cp : _gameModeList) {
			BetMenuObj _bt = new BetMenuObj();
			_bt.setTypeId(String.valueOf(cp.getTypeId()));
			_bt.setName(cp.getName());
			_bt.setBouns(cp.getBouns());
			betMenuListObjs.add(_bt);
		}
		// END 封装 List<BetMenuObj>
		
		//封装  List<BetTargetObj> betTargetObjs
		List<BetTargetObj> betTargetObjs = null;
		
		for(CaiPiaoSimulationPlan p : _planList) {
			betTargetObjs = new ArrayList<BetTargetObj>();
			CaiPiaoSimulationCode queryCode = new CaiPiaoSimulationCode();
			queryCode.setPlanId(p.getId());
			List<CaiPiaoSimulationCode> _codeList = caiPiaoSimulationCodeService.queryAll(queryCode);
			for(CaiPiaoSimulationCode c : _codeList) {
				BetMenuObj _betMenuObj = new BetMenuObj();
				_betMenuObj.setTypeId(String.valueOf(c.getGameModeId()));
				_betMenuObj.setName(c.getGameModeName());
				CaiPiaoBetType betType = caiPiaoBetTypeService.getCaiPiaoBetTypeByTypeId(c.getGameModeId().longValue() , p.getCaiTypeId());
				_betMenuObj.setBouns(betType.getBouns());
				//
				BetTargetObj  betTargetObj = new BetTargetObj();
				betTargetObj.setFirstNumsList(StringUtil.stringToListInteger(c.getBetFristNum(), ","));
				betTargetObj.setSecondNumsList(StringUtil.stringToListInteger(c.getBetSecondNum(), ","));
				betTargetObj.setThirdNumsList(StringUtil.stringToListInteger(c.getBetThirdNum(), ","));
				betTargetObj.setBetMenuObj(_betMenuObj);
				
				betTargetObjs.add(betTargetObj);
			}
			
			//根据中奖，未中奖进行相应操作  更新状态  ，返还用户虚拟币数量
			System.out.println(p.getId() + "---------------------------------" + JSONObject.toJSONString(betTargetObjs) );
			int singerBetMoney = CountTotalBonusUtil.getTotalBonus(betMenuListObjs, betTargetObjs, awardNumbers);
			CaiPiaoSimulationDetail _queryDetail = new CaiPiaoSimulationDetail();
			_queryDetail.setPlanId(p.getId());
			List<CaiPiaoSimulationDetail> detailList = caiPiaoSimulationDetailService.queryAll(_queryDetail);
			if(singerBetMoney > 0) {
				//中奖，更新当期状态，和后面期的状态，返还用户币，更新方案状态
				long returnUserMoney = 0; //需返还给用户的币数量
				long lastPlanMoney = 0; //实际消耗币数量
				long bonus = 0 ; // 中奖金额
				for(CaiPiaoSimulationDetail dt : detailList) {
					if(Integer.parseInt(dt.getFullIssueNo()) == Integer.parseInt(issueNo)) {
						
						/**判断是否中间有漏号, 逻辑： 当前期如果不是 待开奖状态，则为漏号 ，直接退出 不做任何操作 **/
						if(!StringUtils.equals(dt.getStatus(), BetPlanDetailStatus.waitopen.getCode())) {
							return;
						}
						
						lastPlanMoney = dt.getInvestment();
						returnUserMoney = p.getPlanTotalMoney() - dt.getInvestment();
						dt.setOpenCode(openCode);
						bonus = singerBetMoney *  dt.getCurrBetMultiple();
						dt.setBetBonus(Long.valueOf(bonus));
						dt.setStatus(BetPlanDetailStatus.lucker.getCode());
						caiPiaoSimulationDetailService.modify(dt, false);
					}
					
					if(Integer.parseInt(dt.getFullIssueNo()) > Integer.parseInt(issueNo)) {
						dt.setBetBonus(0L);
						dt.setStatus(BetPlanDetailStatus.canel.getCode());
						caiPiaoSimulationDetailService.modify(dt, false);
					}
				}
				
				//修改方状态
				p.setPlanStatus(BetPlanStatus.lucker.getCode());
				p.setLastMoney(lastPlanMoney);
				modify(p, false);
				// ***************************** 重要 ： 投注成功后，扣掉用户模拟币，这里不扣，，，
				
				//加上中奖币  bonus
				userVirtualMoneyService.addUserVirtualMoney(p.getUserId(), bonus, VirtualMoneyType.virtualmoney, VirtualMoneyHistoryType.bet_buons , String.valueOf(p.getId()));
				
				//返还用户的币  returnUserMoney
				userVirtualMoneyService.addUserVirtualMoney(p.getUserId(), returnUserMoney, VirtualMoneyType.virtualmoney, VirtualMoneyHistoryType.bet_return , String.valueOf(p.getId()));				
			}else {
				
				//未中奖， 修改当期状态，判断是否需要修改方案的状态，判断条件，当期是否为该方案最后一期？
				for(int i = 0 ; detailList != null && i < detailList.size() ; i++) {
					CaiPiaoSimulationDetail dt = detailList.get(i);
					
					if(Integer.parseInt(dt.getFullIssueNo()) == Integer.parseInt(issueNo)) {
						
						/**判断是否中间有漏号, 逻辑： 当前期如果不是 待开奖状态，则为漏号 ，直接退出 不做任何操作 **/
						
						if(!StringUtils.equals(dt.getStatus(), BetPlanDetailStatus.waitopen.getCode())) {
							return;
						}
						
						dt.setOpenCode(openCode);
						dt.setBetBonus(Long.valueOf(0));
						dt.setStatus(BetPlanDetailStatus.runing.getCode());
						caiPiaoSimulationDetailService.modify(dt, false);
						
						if(i == (detailList.size() - 1)) {//说明最后一期没有中奖，需要修改
							//修改方状态
							p.setPlanStatus(BetPlanStatus.no_lucker.getCode());
							p.setLastMoney(dt.getInvestment());
							modify(p, false);
						}
						
						// 设置下一期的状态为 待开奖
						
						if((i+1) < detailList.size()) {
							CaiPiaoSimulationDetail nextPlanDetail = detailList.get(i+1);
							nextPlanDetail.setStatus(BetPlanDetailStatus.waitopen.getCode());
							caiPiaoSimulationDetailService.modify(nextPlanDetail, false);
						}
						
					}
					
					
				}
				
			}
			
		}
		
	}
	
	
	
	public CaiPiaoSimulationPlan packageCaiPiaoSimulationPlan(Long userId,Long cai_id,BetObj vo) {
		CaiPiaoSimulationPlan  retObject = new CaiPiaoSimulationPlan();
		retObject.setUserId(userId);
		retObject.setPlanStatus(BetPlanStatus.runing.getCode());
		int _totalMoney = getPlanTotalMoney(vo.getBetAIPlanObjs());
		if(_totalMoney < 1) {
			throw new BaseServiceException("异常, 提交的累计投注金额异常 !");
		}
		retObject.setPlanTotalMoney(Long.valueOf(_totalMoney));
		retObject.setCaiId(cai_id);
		CaiPiao _cai_piao = caiPiaoService.getCaiPiaoObjectByCaiId(cai_id.intValue());
		if(_cai_piao == null) {
			throw new BaseServiceException("提交的CAI_ID非法");
		}
		retObject.setCaiName(_cai_piao.getCaiName());
		retObject.setCaiTypeId(Integer.parseInt(_cai_piao.getCaiTypeId()));
		if(StringUtils.isBlank(getLongIssueNo(vo.getBetAIPlanObjs()))) {
			throw new BaseServiceException("获取首期长期号错误,未获取到长期号!");
		}
		retObject.setBeginIssueNo(getLongIssueNo(vo.getBetAIPlanObjs()));
		retObject.setBetTime(new Date());
		return retObject;
		
		
	}
	
	private int getPlanTotalMoney(List<BetAIPlanObj> list) {
		if(CollectionUtils.isEmpty(list))return 0;
//		List<BetAIPlanObj> _list = list;
//		Collections.reverse(_list);
//		return _list.get(0).getTotalMoney();
		
		for(int i = 0 ; i < list.size() ; i++) {
			if(i == (list.size() - 1)) {
				return list.get(i).getTotalMoney();
			}
		}
		
		return 0;
	}
	
	
	
	
	private String getLongIssueNo(int temp,int _shortIssueNo) {
		
		String _issueNo = "";
		if(_shortIssueNo > 0 && _shortIssueNo < 10) {
			_issueNo = "0" + _shortIssueNo;
		}else {
			_issueNo = "" + _shortIssueNo;
		}
		
		if(temp > _shortIssueNo) {//处理跨天期号,当前处理方案，只能处理向后跨一天的情况，如果出现向后跨多天，则需要对 后一天进行单独处理。
			_issueNo = DateTimeUtil.getDate(DateTimeUtil.addDay(new Date(), 1), "yyMMdd") + _issueNo;
		}else {
			_issueNo = DateTimeUtil.getDate(new Date(), "yyMMdd") + _issueNo;
		}
		
		return _issueNo;
	}
	
	public String getLongIssueNo(List<BetAIPlanObj> planList) {
		if(CollectionUtils.isEmpty(planList)) {
			return null;
		}
		String _issueNo = "";
		BetAIPlanObj _plan = planList.get(0);
		int _shortIssueNo = _plan.getShortIssueno();
		if(_shortIssueNo > 0 && _shortIssueNo < 10) {
			_issueNo = "0" + _shortIssueNo;
		}else {
			_issueNo = "" + _shortIssueNo;
		}
		_issueNo = DateTimeUtil.getDate(new Date(), "yyMMdd") + _issueNo;
		return _issueNo;
	}
	
	
	
	
	
	
	public ResponseEntity<?> getCaiPiaoSimulationPlanList(Long userId,int pageSize,int pageIndex){
		
		List<MyBetListObj> retList = new ArrayList<MyBetListObj>();
		CaiPiaoSimulationPlan _plan = new CaiPiaoSimulationPlan();
		_plan.setUserId(userId);
		_plan.orderById(false);
		
		PageHelper.startPage(pageIndex, pageSize);
		List<CaiPiaoSimulationPlan> plist = this.queryAll(_plan);
		@SuppressWarnings({ "rawtypes", "unchecked" })
		PageInfo page = new PageInfo(plist);
		//System.out.println("查询结果==========================  " + JSONObject.toJSONString(page));
		for(CaiPiaoSimulationPlan p : plist) {
			
			MyBetListObj _myBetListObj = new MyBetListObj();
			_myBetListObj.setPlanId(p.getId().toString());
			_myBetListObj.setCaiType(p.getCaiTypeId().toString());
			_myBetListObj.setCaiName(p.getCaiName());
			_myBetListObj.setCaiId(p.getCaiId().toString());
			_myBetListObj.setStatus(p.getPlanStatus());
			_myBetListObj.setBeginIssueno(p.getBeginIssueNo());
			Map<String,String> map = getPlanDetailInfo(p.getId());
			_myBetListObj.setHasRunPeroid(map.get("openIssueNoCount"));
			_myBetListObj.setTotalPeroid(map.get("issueNoCount"));
			_myBetListObj.setCreateTime(DateTimeUtil.getDate(p.getBetTime(), DateTimeUtil.FORMAT_LONGTIME));
			_myBetListObj.setReward(map.get("betBonus"));
			// totalCost : 方案消耗金额：进行中的和已完成没中奖的给我方案总金额，已取消和已中奖的给我实际消耗金额  
			if(StringUtil.equals(p.getPlanStatus(), BetPlanStatus.runing.getCode()) || StringUtil.equals(p.getPlanStatus(), BetPlanStatus.no_lucker.getCode())) {
				_myBetListObj.setTotalCost(String.valueOf(p.getPlanTotalMoney()));
			}else {
				_myBetListObj.setTotalCost(String.valueOf(p.getLastMoney()));
			}
			//封装 ArrayList<MyBetNumberInfoObj>
			_myBetListObj.setMyBetNumberInfoObjs( getMyBetNumberInfoObjList(p.getId(),p.getCaiTypeId()) );
			retList.add(_myBetListObj);
		}
		Map<String,Object> retMapObject = new HashMap<String,Object>();
		retMapObject.put("list", retList);
		retMapObject.put("pageCount", page.getPages());
		retMapObject.put("rowCount", page.getTotal());
		retMapObject.put("currPageIndex", pageIndex);
		//System.out.println("====================================================================> :   " + JSONObject.toJSONString(retMapObject));
		return new ResponseEntity<>(new ResponseResultModel<Map<String,Object>>(retMapObject),HttpStatus.OK);
	}
	
	public ArrayList<MyBetNumberInfoObj> getMyBetNumberInfoObjList(Long planId, int caiTypeId){
		ArrayList<MyBetNumberInfoObj> retList = new ArrayList<MyBetNumberInfoObj>();
		CaiPiaoSimulationCode _caiPiaoSimulationCode = new CaiPiaoSimulationCode();
		_caiPiaoSimulationCode.setPlanId(planId);
		List<CaiPiaoSimulationCode> list = caiPiaoSimulationCodeService.queryAll(_caiPiaoSimulationCode);
		for(CaiPiaoSimulationCode code : list) {
			MyBetNumberInfoObj obj = new MyBetNumberInfoObj();
			obj.setCaiType(String.valueOf(caiTypeId));
			obj.setBetTypeName(code.getGameModeName());
			obj.setBetTypeId(String.valueOf(code.getGameModeId()));
			if(StringUtil.isNotBlank(code.getBetFristNum())) obj.setFirstNumsList(StringUtil.stringToListInteger(code.getBetFristNum(), ","));
			if(StringUtil.isNotBlank(code.getBetSecondNum())) obj.setSecondNumsList(StringUtil.stringToListInteger(code.getBetSecondNum(), ","));
			if(StringUtil.isNotBlank(code.getBetThirdNum())) obj.setThirdNumsList(StringUtil.stringToListInteger(code.getBetThirdNum(), ","));
			retList.add(obj);
		}
		return retList;
	}
	
	public Map<String,String> getPlanDetailInfo(Long planId){
		
		Map<String,String> retMap = new HashMap<String,String>();
		CaiPiaoSimulationDetail _detail = new CaiPiaoSimulationDetail();
		_detail.setPlanId(planId);
		_detail.orderById(true);
		List<CaiPiaoSimulationDetail> list = caiPiaoSimulationDetailService.queryAll(_detail);
		int issueNoCount = list.size();//总期数
		int openIssueNoCount = 0; //已追期数
		long _betBonus = 0L;
		for(int i = 0 ; list != null && i < list.size() ; i++) {
			CaiPiaoSimulationDetail dt = list.get(i);
			_betBonus = _betBonus + dt.getBetBonus();
			if(StringUtil.equals(dt.getStatus(), BetPlanDetailStatus.lucker.getCode()) || StringUtil.equals(dt.getStatus(), BetPlanDetailStatus.waitopen.getCode())  || StringUtil.equals(dt.getStatus(), BetPlanDetailStatus.runing.getCode())) {
				openIssueNoCount++;
			}
			
		}		
		retMap.put("issueNoCount", String.valueOf(issueNoCount));
		retMap.put("openIssueNoCount", String.valueOf(openIssueNoCount));
		retMap.put("betBonus", String.valueOf(_betBonus));
		return retMap;
		
	}
	
	public ResponseEntity<?> getBetPlanDetailList(Long planId) {
		List<MyBetPlanDetailObj> retList = new ArrayList<MyBetPlanDetailObj>();
		CaiPiaoSimulationDetail _detail = new CaiPiaoSimulationDetail();
		_detail.setPlanId(planId);
		List<CaiPiaoSimulationDetail> list = caiPiaoSimulationDetailService.queryAll(_detail);
		for(CaiPiaoSimulationDetail d : list) {
			
			MyBetPlanDetailObj obj = new MyBetPlanDetailObj();
			obj.setIssueno(d.getFullIssueNo());
			obj.setMultiple(String.valueOf(d.getCurrBetMultiple()));
			obj.setNumbers(StringUtil.stringToArrayListInteger(d.getOpenCode(), ","));
			obj.setReward(String.valueOf(d.getBetBonus()));
			obj.setStatus(d.getStatus());
			obj.setTheoryMaxReward(String.valueOf(d.getMaxBonus()));
			obj.setTheoryMinReward(String.valueOf(d.getMinBonus()));
			obj.setTotalMoney(String.valueOf(d.getInvestment()));
			obj.setCurrentMoney(String.valueOf(d.getCurrentMoney()));
			obj.setAwardTime(DateTimeUtil.getDate(d.getOpenTime(), DateTimeUtil.FORMAT_LONGTIME));
			retList.add(obj);
		}
		return new ResponseEntity<>(new ResponseResultModel<List<MyBetPlanDetailObj>>(retList),HttpStatus.OK);
	}
	
	
	
}





